﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace June_6_2021
{
    enum Guess
    {
        剪刀 = 1,
        石头,
        布
    }
    class Player
    {
        public string PName { get; set; }

        public Player() { }
        public Player(string pname)
        {
            this.PName = pname;
        }

        Robot r = new Robot();
        Random sj = new Random();
        int count = 0;
        int PWin = 0;
        int RWin = 0;
        public void Game()
        {           
            r.ChooseRival();
            Console.WriteLine("请输入您的姓名：");
            PName = Console.ReadLine();
            Console.WriteLine($"{PName} VS {r.RName} 对战");

            Console.WriteLine("开始游戏吗？（y/n）");
            string key = Console.ReadLine();
            if (key == "y")
            {
                count++;
            }
            switch (key)
            {
                case "y":
                    start();
                    break;
                case "n":
                    Console.WriteLine("游戏结束");
                    break;
                default:
                    break;
            }
        }

        public void start() //开始游戏
        {
            Console.WriteLine("请出拳:1.剪刀 2.石头 3.布（输入相应数字：）");
            Solo sl = new Solo();
            sl.PIn();
            Console.WriteLine($"{PName}：出拳：{sl.PInput}");
            Console.WriteLine("请出拳:1.剪刀 2.石头 3.布（输入相应数字：）");
            sl.RIn();
            Console.WriteLine($"{r.RName}:出拳：{sl.RInput}");

            if (sl.PInput == "剪刀")
            {
                if (sl.RInput == "剪刀")
                {
                    Console.WriteLine("和局，真衰！嘿嘿，等着瞧吧！");
                }
                else if (sl.RInput == "石头")
                {
                    Console.WriteLine($"笨蛋，{PName}输了");
                    RWin++;
                }
                else if (sl.RInput == "布")
                {
                    Console.WriteLine($"恭喜，{PName}赢了");
                    PWin++;
                }
            }

            if (sl.PInput == "石头")
            {
                if (sl.RInput == "石头")
                {
                    Console.WriteLine("和局，真衰！嘿嘿，等着瞧吧！");
                }
                else if (sl.RInput == "布")
                {
                    Console.WriteLine($"笨蛋，{PName}输了");
                    RWin++;
                }
                else if (sl.RInput == "剪刀")
                {
                    Console.WriteLine($"恭喜，{PName}赢了");
                    PWin++;
                }
            }

            if (sl.PInput == "布")
            {
                if (sl.RInput == "布")
                {
                    Console.WriteLine("和局，真衰！嘿嘿，等着瞧吧！");
                }
                else if (sl.RInput == "剪刀")
                {
                    Console.WriteLine($"笨蛋，{PName}输了");
                    RWin++;
                }
                else if (sl.RInput == "石头")
                {
                    Console.WriteLine($"恭喜，{PName}赢了");
                    PWin++;
                }
            }

            Console.WriteLine("是否开启下一轮？<y/n>");
            string key = Console.ReadLine();
            if (key == "y")
            {
                count++;
            }
            switch (key)
            {
                case "y":
                    start();
                    break;
                case "n":
                    break;
                default:
                    Console.WriteLine("输入错误，请认真查看规则！");
                    break;
            }
            Console.WriteLine("==========================");
            Console.WriteLine($"{r.RName} VS {PName}");
            Console.WriteLine("对战次数:" + count);
            Console.WriteLine();
            Console.WriteLine("姓名     得分");
            Console.WriteLine($"{PName}      {PWin}");
            Console.WriteLine($"{r.RName}      {RWin}");
            if (RWin > PWin)
            {
                Console.WriteLine($"结果：{r.RName}赢，{PName}笨蛋");
            }
            else if (RWin == PWin)
            {
                Console.WriteLine($"结果：{PName}和{r.RName}打成平手");
            }
            else
            {
                Console.WriteLine($"结果：{PName}赢，{r.RName}笨蛋");
            }

            Console.WriteLine("要开始下一局吗？<y/n>");
            string input = Console.ReadLine();
            switch (input)
            {
                case "y":
                    start();
                    break;
                case "n":
                    Console.WriteLine("系统退出");
                    break;
                default:
                    Console.WriteLine("输入有误！！！");
                    break;
            }
        }
    }
}
